#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File Name: JsonParse.py
# Author: bobo
# Created Time: 20221109

import json


def open_json_file(path: str):
    """打开path对应的json文件"""
    with open(path, "r", encoding="utf-8") as f:
        tmp = json.load(f)
    return tmp


def write_json_file(path: str, value):
    """将json数据写入文件中。必须要符合json格式的dict或list才可以写入"""
    with open(path, "w+", encoding="utf-8") as fw2:
        json.dump(value, fw2, indent=2, sort_keys=True, ensure_ascii=False)


# 使用样例 config.json
# """
# {
#    "tken":"用户TOKEN",
#    "site":"站点链接",
#    "published":true
# }
# """
# UserConfig = open_json_file("config.json")
# BASE_URL = UserConfig["ste"]
# API_KEY = UserConfig["token"]
